package character;

import utilities.Timespan;
import utilities.WorldDate;
import utilities.WorldState;

/**
 * Age class.
 * @author pcdejager
 */
public final class Age {
    /**
     * Constructor.
     * @param b The birth date
     */
    public Age(final WorldDate b) {
        born = (WorldDate) b.clone();
    }
    /**
     * Get the character birth date.
     * @return The birth date
     */
    public WorldDate getBirthday() {
        return born;
    }
    /**
     * Get the character age in years.
     * @return The age in years
     */
    public int years() {
        return WorldDate.calculateYears(born, WorldState.getState().now());
    }
    /**
     * Get the character age in days.
     * @return The age in days
     */
    public int days() {
        return WorldDate.calculateDays(born, WorldState.getState().now());
    }
    /**
     * Get the character age as a timespan.
     * @return The age
     */
    public Timespan getAge() {
        WorldDate now = WorldState.getState().now();
        return new Timespan(born, now);
    }
    /**
     * The birth date.
     */
    private WorldDate born = null;
}
